import { get, post, deleter, put } from './http'
import type { UserType, RoomType, FoodType } from '@/types'

//登录
export function login(user: UserType) {
	return post('/user/login', user)
}

//登出
export function logout() {
	return post('/user/logout', null)
}

//注册
export function register(user: UserType) {
	return post('/user/register', user)
}

//修改密码
export function modifyPassword(id: string, oldPassword: string, newPassword: string) {
	return post('/user/modifyPassword', { id, oldPassword, newPassword })
}

//通过id查询用户
export function getUserById(id?: string) {
	// ?表示可有可无
	return get('/user', { id })
}

//获取用户分页列表
export function getUserListPage(page:number,pageSize:number){
	return get('/user/page',{page,pageSize})
}

//获取当前用户角色
export function getCurrentUserRole() {
	return post('/user/role', {})
}

//下载文件
export function downloadFile(name?: string) {
	return get('/file/download', { name })
}

//修改用户
export function modifyInfo(user: UserType) {
	return post('/user/modify', user)
}

//删除用户
export function deleteUser(id: string) {
	return post('/user/delete', { id })
}

//增加房间
export function addRoom(room: RoomType) {
	return post('/room/add', room)
}

//修改房间
export function modifyRoom(room: RoomType) {
	return post('/room/modify', room)
}

//查询房间
export function selectRoom(id: string) {
	return post('/room/select', { id })
}

//房间列表（无参数默认返回全部房间）
export function selectRoomList(page:number,pageSize:number) {
	return get('/room/list', {page,pageSize})
}
//删除房间
export function deleteRoom(id: string) {
	return post('/room/delete', { id })
}
//获取分页餐饮列表
export function getFoodPageList(page:number,pageSize:number) {
	return get('/food/page', { page,pageSize })
}
//修改餐饮
export function modifyFood(food:FoodType) {
	return post('/food/modify', food )
}
//删除餐饮
export function deleteFood(id: string) {
	return post('/food/delete', {id} )
}

//获取房间灯光信息
export function getTolietLight(room: RoomType) {
	return post('/room/toliet', room )
}

//获取评论分页列表
export function getContentListPage(page:number,pageSize:number){
	return get('/board/page',{page,pageSize})
}